# -*- coding: iso-8859-2 -*-

import os

class Path:
    '''
    Class providing paths to the specified directories 
    '''
    
    def getMainDir():
        '''
        Method returning path to the main folder of
        the application. On the same level there are 
        directories with resources.
        @return path to the main folder of the application
        @raise IOError: if path not exists 
        '''
        currentDir = os.getcwd().split(os.sep)
        result = ""
        for entry in currentDir:
            result += entry + os.sep
            if entry == "AuthorAnalyzer":
                if os.path.exists(result):
                    return result
                raise IOError
    
    def getResourceDir():
        '''
        Function returning path to the directory 
        with resources
        @return path to the resource directory
        @raise IOError: if path not exists 
        '''
        return os.path.join(Path.getMainDir(), "resources")
    
    def getCategoriesDir():
        '''
        Function returning path to the directory 
        with properties essential for categorization 
        @return path to the folder with categories resources
        @raise IOError: if path not exists 
        '''
        return os.path.join(Path.getResourceDir(), "categories")
    
    def getInfo1Dir():
        '''
        @return path to the directory with stored files
        from info1 archive
        '''
        return os.path.join(Path.getMainDir(), "info1")
    
    def getSubjectsDir():
        '''
        Function returning path to the directory 
        with properties essential for subject reconition 
        @return path to the folder with subject resources
        @raise IOError: if path not exists 
        '''
        return os.path.join(Path.getResourceDir(), "subjects")
    
    def getSlotDir():
        '''
        Function returning path to the directory 
        with persistent slots
        @return path to the resource directory
        @raise IOError: if path not exists 
        '''
        return os.path.join(Path.getResourceDir(), "slots")
    
    getMainDir = staticmethod(getMainDir)
    getResourceDir = staticmethod(getResourceDir)   
    getCategoriesDir = staticmethod(getCategoriesDir)
    getInfo1Dir = staticmethod(getInfo1Dir)    
    getSubjectsDir = staticmethod(getSubjectsDir)
    getSlotDir = staticmethod(getSlotDir)
    
if __name__ == "__main__":
    print Path.getCategoriesDir()
    print Path.getMainDir()
    print Path.getResourceDir()